Although the kernel keeps track of load average, it provides no interface to programmers who wish to see that information. There is a powerful tool available for situations where there is no interface to a piece of kernel data; the program may read kernel memory directly. This power is accompanied by a certain risk: programs that read kernel memory are unlikely to be portable from one Unix system to another, and they may not even be portable on the same system from one release to another.
The example in this directory may be used as a model of how to browse kernel memory for a useful data element, or the example may be used without modification in your application.
The function that does all the work is named loadAverage(), and it is found in file load_avg.c. An application calling this function must #include load_avg.h. The file main.c contains a trivial driver that calls loadAverage. Makefile puts it all together.
Program load_avg (and any other program calling loadAverage) needs to be installed setuid to root.
Some of your customers will not like installing a program setuid to root. For maximum acceptance, you should: